#include <stdio.h>
#include <string.h>

inline int idx(char c) { return c - 'a'; }

int main(int argc, const char *argv[]) {
  int table[26];
  int loop = 0;
  int max_i = 0, max_len = 0;
  const char *str = "abcacfrar";
  int len = strlen(str);
  for (int i = 0; i < 26; ++i) table[i] = -1;
  for (int i = 0; i < len; ++i) {
    if (table[idx(str[i])] >= loop) {
      if (i - loop > max_len) {
        max_i = loop;
        max_len = i - loop;
      }
      loop = i;
    }
    table[idx(str[i])] = i;
  }
  for (int i = 0; i < max_len; ++i) {
    printf("%c", str[max_i + i]);
  }
  printf("\n");
  return 0;
}

